package com.ruoyi.course.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.course.mapper.CdTopicQuestionMapper;
import com.ruoyi.course.domain.CdTopicQuestion;
import com.ruoyi.course.service.ICdTopicQuestionService;

/**
 * 留言板Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-21
 */
@Service
public class CdTopicQuestionServiceImpl implements ICdTopicQuestionService 
{
    @Autowired
    private CdTopicQuestionMapper cdTopicQuestionMapper;

    /**
     * 查询留言板
     * 
     * @param questionId 留言板主键
     * @return 留言板
     */
    @Override
    public CdTopicQuestion selectCdTopicQuestionByQuestionId(Long questionId)
    {
        return cdTopicQuestionMapper.selectCdTopicQuestionByQuestionId(questionId);
    }

    /**
     * 查询留言板列表
     * 
     * @param cdTopicQuestion 留言板
     * @return 留言板
     */
    @Override
    public List<CdTopicQuestion> selectCdTopicQuestionList(CdTopicQuestion cdTopicQuestion)
    {
        return cdTopicQuestionMapper.selectCdTopicQuestionList(cdTopicQuestion);
    }

    /**
     * 新增留言板
     * 
     * @param cdTopicQuestion 留言板
     * @return 结果
     */
    @Override
    public int insertCdTopicQuestion(CdTopicQuestion cdTopicQuestion)
    {
        cdTopicQuestion.setQuestionId(System.currentTimeMillis());
        cdTopicQuestion.setUserId(SecurityUtils.getUserId());
        cdTopicQuestion.setCreateTime(DateUtils.getNowDate());
        return cdTopicQuestionMapper.insertCdTopicQuestion(cdTopicQuestion);
    }

    /**
     * 修改留言板
     * 
     * @param cdTopicQuestion 留言板
     * @return 结果
     */
    @Override
    public int updateCdTopicQuestion(CdTopicQuestion cdTopicQuestion)
    {
        return cdTopicQuestionMapper.updateCdTopicQuestion(cdTopicQuestion);
    }

    /**
     * 批量删除留言板
     * 
     * @param questionIds 需要删除的留言板主键
     * @return 结果
     */
    @Override
    public int deleteCdTopicQuestionByQuestionIds(Long[] questionIds)
    {
        return cdTopicQuestionMapper.deleteCdTopicQuestionByQuestionIds(questionIds);
    }

    /**
     * 删除留言板信息
     * 
     * @param questionId 留言板主键
     * @return 结果
     */
    @Override
    public int deleteCdTopicQuestionByQuestionId(Long questionId)
    {
        return cdTopicQuestionMapper.deleteCdTopicQuestionByQuestionId(questionId);
    }
}
